<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">

<script>

  let num = document.querySelector("#i1");
  let imgName;
  function f(x){
    if (x===1){
      imgName = "../11.jpg";
    }else {
      imgName = "../22.jpg";
    }
    for (let j = 0;j<num.value;j++){
      let i = document.createElement("img");
      i.src = imgName;
      document.body.append(i);
    }

  }
</script>

</body>
</html>